package mes.kanban.config;

import java.nio.charset.Charset;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import mes.kanban.exception.MyExceptionResolve;


/**
 * 配置
 * @author gjy
 *
 * 2018年1月24日下午5:18:45
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {


    @Bean
    public HttpMessageConverter<String> responseBodyConverter() {
        StringHttpMessageConverter converter = new StringHttpMessageConverter(
                Charset.forName("UTF-8"));
        return converter;
    }

    @Bean
    OperateAspect operateAspect() {
    	return new OperateAspect();
    }
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    	registry.addInterceptor(new OperateAspect()).addPathPatterns("/**");
    	registry.addInterceptor(new MyExceptionResolve()).addPathPatterns("/**");
    }
    
}
